Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evolutionary based black-box adversarial attack. #2215

Closed
wants to merge 19 commits into from

Conversation

aliotopal
Copy link

@aliotopal aliotopal commented Jul 5, 2023

Description

I have developed an evolutionary algorithm-based black-box adversarial attack (attack_EA). It is added in evasion attacks section.

Fixes # (issue)

Type of change

Please check all relevant options.

  • Improvement (non-breaking)
  • Bug fix (non-breaking)
  • New feature (non-breaking)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Testing

Please describe the tests that you ran to verify your changes. Consider listing any relevant details of your test configuration.

  • Test A
  • Test B

Test Configuration:

  • OS
  • Python version
  • ART version or commit number
  • TensorFlow / Keras / PyTorch / MXNet version

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@aliotopal
Copy link
Author

Signed-off-by: Ali Osman TOPAL [email protected]

@aliotopal aliotopal closed this Jul 5, 2023
@aliotopal aliotopal reopened this Jul 5, 2023
@beat-buesser
Copy link
Collaborator

Hi @aliotopal Thank you for your pull request! I'll change the target branch to the dev-branch for next release 1.16.

@beat-buesser beat-buesser changed the base branch from dev_1.15.1 to dev_1.16.0 July 5, 2023 15:07
import logging
from typing import Optional, TYPE_CHECKING

import numpy as np

Check notice

Code scanning / CodeQL

Module is imported more than once Note

This import of module numpy is redundant, as it was previously imported
on line 2
.
art/attacks/evasion/attack_EA.py Fixed Show resolved Hide resolved
art/attacks/evasion/attack_EA.py Fixed Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Jul 5, 2023

Codecov Report

Merging #2215 (72a635d) into dev_1.16.0 (ad7520c) will decrease coverage by 0.74%.
The diff coverage is 0.00%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Impacted file tree graph

@@              Coverage Diff               @@
##           dev_1.16.0    #2215      +/-   ##
==============================================
- Coverage       85.62%   84.88%   -0.74%     
==============================================
  Files             324      325       +1     
  Lines           29323    29458     +135     
  Branches         5405     5413       +8     
==============================================
- Hits            25108    25006     -102     
- Misses           2837     3075     +238     
+ Partials         1378     1377       -1     
Files Coverage Δ
art/attacks/evasion/attack_EA.py 0.00% <0.00%> (ø)

... and 4 files with indirect coverage changes

@beat-buesser beat-buesser self-requested a review July 6, 2023 15:09
@beat-buesser beat-buesser added the enhancement New feature or request label Jul 6, 2023
@beat-buesser beat-buesser self-assigned this Jul 6, 2023
@beat-buesser beat-buesser added this to the ART 1.16.0 milestone Jul 6, 2023
@beat-buesser
Copy link
Collaborator

Hi @aliotopal Could you please take a look at the Style Checks? You can solve most of the issues by running Black formatter version black==21.12b0 with commands black --line-length 120 art/ and black --line-length 120 tests/.

@aliotopal
Copy link
Author

aliotopal commented Sep 5, 2023

Hi @beat-buesser, I have done the style check, it should be ok now. Can you please have a look if everything is ok? Best,

[email protected]
The style check is done. Redundant parts are removed.
art/attacks/evasion/attack_EA.py Fixed Show resolved Hide resolved
Fixed trailing whitespaces, blank lines, missing values errors.
@beat-buesser beat-buesser modified the milestones: ART 1.16.0, ART 1.17.0 Sep 22, 2023
@aliotopal
Copy link
Author

Hi @beat-buesser,
Is there anything that I need to do about the code?

The attack was not compatible with framework libraries, fixed and now works.
art_2 changed with art
@aliotopal
Copy link
Author

Hi @beat-buesser,
We have updated the code so it is compatible with ART libraries and the attack is working now. It is written in Keras only. Can you please have a look when you have time?

Comment on lines 63 to 70
# def _get_class_prob(preds: np.ndarray, class_no: np.array) -> np.ndarray:
# '''
# :param preds: an array of predictions of individuals for all the categories: (40, 1000) shaped array
# :param class_no: for the targeted attack target category index number; for the untargeted attack ancestor
# category index number
# :return: an array of the prediction of individuals only for the target/ancestor category: (40,) shaped array
# '''
# return preds[:, class_no]

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
Style check errors are fixed.
1. module name changed from attack_EA.py to attack_ea
2. random.shuffle() is removed, it was redundant.
3. x_ is changed to x_temp
@aliotopal
Copy link
Author

aliotopal commented Oct 12, 2023

Hi @beat-buesser, I went over the style errors, it should be fine now (I hope).
Style Check:

  1. Module name "attack_EA" doesn't conform to snake_case naming style (invalid-name): changed name to attack_ea
  2. Variable name "x_" doesn't conform to snake_case naming style (invalid-name): x_ changed to x_temp
  3. Argument 1 to "shuffle" has incompatible type "ndarray[Any, Any]"; expected "MutableSequence[Any]: removed function, it was redundant.
  4. generate function arguments are changed according to the superclass.

For the other errors, I don't know what to do.

can you please have a look once more?

@aliotopal
Copy link
Author

Dear @beat-buesser,

I am sorry, I know I am becoming a pain :(, but when you have time can you please have a look at our attack?

@beat-buesser beat-buesser modified the milestones: ART 1.17.0, ART 1.18.0 Dec 27, 2023
@aliotopal
Copy link
Author

Dear @beat-buesser,

Finally, style check is giving only this error: "Class name "attack_ea" doesn't conform to PascalCase naming style (invalid-name)" I don't want to change file name, if it is ok. Besides that, there are some more errors in "mypy" but it seems they are not related to our attack. Can you please have a look and give us direction?

@aliotopal
Copy link
Author

aliotopal commented Feb 6, 2024 via email

@aliotopal
Copy link
Author

aliotopal commented Feb 13, 2024 via email

@beat-buesser beat-buesser modified the milestones: ART 1.18.0, ART 1.19.0 Jun 16, 2024
@beat-buesser beat-buesser deleted the branch Trusted-AI:dev_1.16.0 October 1, 2024 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants